package com.matrix.java.chap_04;

import java.util.Scanner;

/*
    十进制转十六进制
 */
public class Ex4_11 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("Enter a decimal value (0 to 15): ");
        int demical = input.nextInt();
        if (demical < 0 || demical > 15) {
            System.out.println(demical + " is an invalid input");
        } else if (demical <= 9) {
            System.out.println("The hex value is " + demical);
        } else {
            System.out.println("The hex value is " + (char) (demical - 10 + 'A'));
        }
        input.close();
    }
}
